home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 415 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: time/date algorithms
  5. Date: Fri, 05 Jan 96 02:23:43 GMT
  6. Organization: none
  7. Message-ID: <820808623snz@genesis.demon.co.uk>
  8. References: <30EC5A1F.3DE0@sandpoint.com>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <30EC5A1F.3DE0@sandpoint.com>
  15.            mark_thomas@sandpoint.com "Mark Thomas" writes:
  16.  
  17. >A co-worker of mine is looking for an algorithm what
  18. >works something like this:  given a week number 1-52
  19. >(or 0-51 I suppose) and a year, the month and day of the
  20. >sunday in that week is output.  He swears he's seen
  21. >it in a book, and doesn't want to have to re-create it.
  22.  
  23. First you have to define what you mean by a week number. There are many
  24. definitions to choose from. For example there are 2 defined by the ANSI
  25. strftime %U and %W conversion specifiers, there are ISO 8601 week numbers
  26. and there might also be simpler definitions such at the first 7 days of
  27. the year being in week 1, and so on. It is probably simplest if your
  28. co-worker defines what he understands by week number.
  29.  
  30. Incidentally 52 weeks only accounts for 364 days so there are more than 52
  31. weeks in a year.
  32.  
  33. >Anyone have this [bizarre] algorithm laying around somewhere,
  34. >or know where it can be found?  Please reply by email
  35. >if you do -- thanks alot.
  36.  
  37. No I don't! :-) However it should be very easy to write once we know
  38. what precisely your co-worker needs.
  39.  
  40. -- 
  41. -----------------------------------------
  42. Lawrence Kirby | fred@genesis.demon.co.uk
  43. Wilts, England | 70734.126@compuserve.com
  44. -----------------------------------------
  45.